﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Serviio.API
{
    public class ServiioBrowsingCategory
    {
        public string Id { get; private set; }
        public string Title { get; private set; }
        public string VisibilityString { get; set; }

        public List<ServiioBrowsingCategory> SubCategories { get; private set; }

        private static List<KeyValuePair<string, string>> visibilityChoices = new List<KeyValuePair<string, string>>();
        public static List<KeyValuePair<string, string>> VisibilityChoices
        {
            get
            {
                return visibilityChoices;
            }
        }

        static ServiioBrowsingCategory()
        {
            visibilityChoices.Add(new KeyValuePair<string, string>("DISPLAYED", "Display Category"));
            visibilityChoices.Add(new KeyValuePair<string, string>("CONTENT_DISPLAYED", "Display Content Only"));
            visibilityChoices.Add(new KeyValuePair<string, string>("DISABLED", "Disabled"));
        }

        public enum Visibilities
        {
            Displayed = 0,
            ContentDisplayed = 1,
            Disabled = 2,
            Unknown
        }

        private string[] visibilityStrings =
        {
            "DISPLAYED",
            "CONTENT_DISPLAYED",
            "DISABLED"
        };

        public Visibilities Visibility
        {
            get
            {
                for (int i = 0; i < visibilityStrings.Length; i++)
                    if (visibilityStrings[i].Equals(VisibilityString))
                        return (Visibilities)i;

                return Visibilities.Unknown;
            }
            set
            {
                VisibilityString = visibilityStrings[(int)value];
            }
        }

        internal ServiioBrowsingCategory(string id, string title, string visibilityString)
        {
            Id = id;
            Title = title;
            VisibilityString = visibilityString;

            SubCategories = new List<ServiioBrowsingCategory>();
        }
    }
}
